1 <?php
2
3 session_start();
4
5 include_once(
'includes/config.php');
6
7 #Check
if the user has items in cart and is logged in
8 if
(isset($_SESSION['email']) && isset($_SESSION['token'])) {
9
10     #Store retrieved session values
11     $email = $_SESSION[
'email'];
12     $token = $_SESSION[
'token'];
13
14     #
if email and token is set check them against the database, retrieve and store the email and token retrieved for comparison
15
16     $sql =
"SELECT user_email, user_token from users WHERE user_email = '$email'";
17     $retrieveStmt = $db_conn -> prepare($sql);
18     $retrieveStmt -> execute();
19
20     $user_row = $retrieveStmt -> fetch(PDO::FETCH_ASSOC);
21
22     
if ($user_row > 0) {
23         # store values to be compared
24         $_server_email = $user_row[
'user_email'];
25         $_server_token = $user_row[
'user_token'];
26     }
27
28     
if ($email == $_server_email && $token == $_server_token)
29     {
30         $arr = explode(
"@", $_SESSION['email'], 2);
31         $cartName = $arr[
0] . '_cart';
32
33         $getCartProducts = $db_conn -> prepare(
"SELECT * FROM $cartName");
34         $getCartProducts -> execute();
35
36         $cartProducts = $getCartProducts -> fetchAll();
37         $totalCartProducts = $getCartProducts -> rowCount();
38     }
39
40     
if ($totalCartProducts > 0 ) {
41         
42     }
else {
43         header(
'Location: products');
44     }
45
46 }
else {
47     header(
'Location: index');
48 }
49
50 ?>
51
52 <!DOCTYPE html>
53 <html>
54 <head>
55     <meta charset=
"utf-8" />
56     <meta http-equiv=
"X-UA-Compatible" content="IE=edge">
57     <title>Shipping | MSwiss</title>
58     <meta name=
"viewport" content="width=device-width, initial-scale=1">
59
60     <!-- Favicons -->
61     <link rel=
"icon" type="image/png" href="images/icons/favicon-32x32.png" sizes="32x32" />
62     <link rel=
"icon" type="image/png" href="images/icons/favicon-128.png" sizes="128x128" />
63
64     <!-- Main CSS-->
65     <link rel=
"stylesheet" type="text/css" media="screen" href="css/main.css" />
66
67     <!-- Products CSS -->
68     <link rel=
"stylesheet" type="text/css" media="screen" href="css/products.css" />
69
70     <!-- Roboto font CDN -->
71     <link href=
"https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i" rel="stylesheet">
72
73 </head>
74 <body>
75
76     <div
class="side-menu">
77         <ul>
78             <li>
79                 <a href=
"index.php">
80                     Home
81                 </a>
82             </li>
83             <li>
84                 <a href=
"products.php">
85                     Shop
86                 </a>
87             </li>
88             <li>
89                 <a href=
"cart.php" class="active-link">
90                     Cart
91                 </a>
92             </li>
93             <li>
94                 <a href=
"index.php">
95                     About
96                 </a>
97             </li>
98             <li>
99                 <a href=
"index.php">
100                     Contact
101                 </a>
102             </li>
103         </ul>
104
105         <a href=
"#" class="disclaimer">Privacy Policy</a>
106         <a href=
"#" class="disclaimer">Disclaimer</a>
107     </div>
108
109     <div
class="clearfix"></div>
110
111     <div
class="overlay">
112
113     </div>
114
115     <div
class="clearfix"></div>
116     
117     <div
class="login-wrapper">
118         <h3>Login</h3>
119         <form id=
"login-form">
120             <input type=
"email" id="login-email" name="login-email" placeholder="Email Address" required/>
121             <input type=
"password" id="login-password" name="login-password" placeholder="Password" required/>
122             <p></p>
123             <input id=
"login-btn" type="submit" value="Log in" />
124         </form>
125     </div>
126
127     <div
class="signup-wrapper">
128         <h3>Sign up</h3>
129         <form id=
"signup-form">
130             <input type=
"text" id="signup-name" placeholder="Name*" required/>
131             <input type=
"email" id="signup-email" placeholder="Email Address*" required/>
132             <input type=
"password" id="signup-password" placeholder="Password*" required/>
133             <input type=
"text" id="signup-address" placeholder="Address*" required/>
134             <p></p>
135             <input id=
"signup-btn" type="submit" value="Sign up" />
136         </form>
137     </div>
138
139     <div
class="container">
140
141         <nav>
142             <div
class="menu-container">
143                 <div
class="menu-icon">
144                     <span
class="menu-aria"></span>
145                     <span
class="menu-aria"></span>
146                     <span
class="menu-aria"></span>
147                     <div
class="menu-text">
148                         <p>Menu</p>
149                     </div>
150                 </div>
151                 <div
class="menu-login-signup">
152                     <?php
153                     
if (isset($_SESSION['email']) && isset($_SESSION['token'])) {
154                         
if ($email == $_server_email && $token == $_server_token)
155                         {
156                             echo
'<a href="includes/logout.php" class="user-logout">Logout</a>';
157                         }
158                     }
else {
159                         echo
'<a href="#" class="login">Login</a>
160                         <a href=
"#" class="signup">Signup</a>';
161                     }
162                     ?>
163                 </div>
164                 <div
class="menu-cart">
165                     <div
class="cart-count">
166                         <p>
167                             <?php echo $totalCartProducts; ?>
168                         </p>
169                     </div>
170                     <p>Cart</p>
171                 </div>
172             </div>
173         </nav>
174
175         <div
class="products-container">
176             <div
class="address-wrapper">
177                 <h2>Shipping Address</h2>
178                 <p
class="status">Fill City</p>
179                 <form id=
"address-form">
180                     <input type=
"text" placeholder="Address" id="shipping-address" required>
181                     <input type=
"text" placeholder="City" id="shipping-city" class="address_half_input margin-right" required>
182                     <input type=
"text" placeholder="State" id="shipping-state" class="address_half_input" required>
183                     <input type=
"text" placeholder="Landmark" id="shipping-landmark" class="address_half_input margin-right" required>
184                     <input type=
"text" placeholder="Pincode" id="shipping-pincode" class="address_half_input" required>
185                     <input type=
"submit" value="Go to Payment">
186                 </form>
187             </div>
188         </div>
189     </div>
190
191     <!-- jQuery CDN -->
192     <script
193     src=
"https://code.jquery.com/jquery-3.3.1.min.js"
194     integrity=
"sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
195     crossorigin=
"anonymous"></script>
196
197     <!-- Custom JS -->
198     <script src=
"js/main.js"></script>
199 </body>
200 </html>


Gõ tìm kiếm nhanh...